//
//  MainTabBarController.m
//  LotteryTicket
//
//  Created by wpapple on 16/5/24.
//  Copyright © 2016年 红红火火恍恍惚惚嘿嘿嘿. All rights reserved.
//

#import "MainTabBarController.h"
#import "TabBarView.h"

@interface MainTabBarController()<TabBarViewDelegate>


@end

@implementation MainTabBarController

-(void)viewDidLoad{
    [super viewDidLoad];
    
    
    [self loadChildController];

    self.selectedIndex = 0;
    
    TabBarView * tabBarView = [[TabBarView alloc]init];
    
    tabBarView.delegate = self;
    
    tabBarView.frame = self.tabBar.bounds;
    
    [self.tabBar addSubview:tabBarView];
    
    
    
}

-(void)loadChildController{
    
    //往TabBar添加控制器
    
//    HallViewController * hallViewController = [[HallViewController alloc]init];
//    
//    HallNavgationController * hallNavgationController = [[HallNavgationController alloc]initWithRootViewController:hallViewController];
//    
//    
//    MyLotteryViewController * myLotteryViewController = [[MyLotteryViewController alloc]init];
//
//    MyLotteryNavgationController * myLotteryNavgationController = [[MyLotteryNavgationController alloc]initWithRootViewController:myLotteryViewController];
//    
//    
//    HistoryViewController * historyViewController = [[HistoryViewController alloc]init];
//    
//    HistoryNavgationController * historyNavgationController = [[HistoryNavgationController alloc]initWithRootViewController:historyViewController];
//    
//    
//    DiscoverViewController * discoverViewController = [[DiscoverViewController alloc]init];
//    
//    DiscoverNavgationController * discoverNavgationController = [[DiscoverNavgationController alloc]initWithRootViewController:discoverViewController];
//    
//    
//    
//    ArenaViewController * arenaViewController = [[ArenaViewController alloc]init];
//    
//    ArenaNavgationController * arenaNavgationController = [[ArenaNavgationController alloc]initWithRootViewController:arenaViewController];
//    
//    
//    self.viewControllers = @[hallNavgationController,myLotteryNavgationController,historyNavgationController,discoverNavgationController,arenaNavgationController];
    
    [self addStoryBoardToSelf:@"Hall"];
    [self addStoryBoardToSelf:@"Arena"];
    [self addStoryBoardToSelf:@"Discover"];
    [self addStoryBoardToSelf:@"History"];
    [self addStoryBoardToSelf:@"MyLottery"];
    
    [self.tabBar setBarTintColor:[UIColor blackColor]];
}

-(void)addStoryBoardToSelf:(NSString *)name{
    UIStoryboard * sb = [UIStoryboard storyboardWithName:name bundle:nil];
    [self addChildViewController:[sb instantiateInitialViewController]];
}

-(void)tabBarView:(TabBarView *)tabBarView didBtnClick:(TabBarButton *)button{
    self.selectedIndex = button.tag;
}

@end
